This repository was archived by the owner on Mar 4, 2020. It is now read-only.
docs(Props): improve table with props#1634
Merged
layershifter merged 12 commits intomasterfrom Jul 17, 2019
Merged
Conversation
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BREAKING CHANGES
LoaderPositionis no longer exported.Problem
To generate proper playgrounds for components we need to have a set of values props. It's impossible to get them from strings.
Allow to use Markdown in props description
This will allow us provide more meaningful descriptions for props.
Missing default values
Only values that were specified by
@defaulttag in JSX were present, forLoaderwe have missedas,delay,labelPositionandsize💥✅ Fixed by update of
parseDefaultValue:Unable to manipulate values
Previously we had just string as values (
"gap.smaller" | "gap.small" | "gap.medium" | "gap.large") fromreact-typescript-docgen, so we can't to use them for playground generation.✅ An updated
parseType()function powered by Babel parses these strings and create proper definition structure:{ "types": [ {"value": "gap.smaller"}, {"value": "gap.small"}, {"value": "gap.medium"}, {"value": "gap.large"} ], "name": "gap", },Why use Babel in
parseType()?Only AST parser can provide proper output. Any implementation based on regexps will be fragile on things like generic types.
Why not use only Babel?
It will be hard to resolve types that are coming interfaces
CommonProps, i.e. Babel good at parse, but it can't resolve TS types.Handle edge cases
react-typescript-docgenusestypeToString()to generate strings with types mentioned above. Sometimes it generates things like this:ℹ️ I tried to configure output of
typeToString()manually via 3rd param (TypeFormatFlags), but it still resolved types.✅ Fixed by direct lookup in Babel AST, see
getTypeFromBabelTree()Wrong
asprop definitionIt was marked as required and missed description.
🆚
Hard to understand what props can be passed to slot
What can be passed to
clearIndicator?Based on #1605 we know which props are used. With parsed types we can obviously understand relationship between components. In this example,
BoxPropsis a link toBoxcomponent 🚀